﻿<UserControl x:Class="XamlHelpmeet.UI.Editors.DynamicFormEditor"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:cvtrs="clr-namespace:XamlHelpmeet.UI.Converters"
             xmlns:enums="clr-namespace:XamlHelpmeet.UI.Enums"
             xmlns:local="clr-namespace:XamlHelpmeet.UI.Editors"
             MinWidth="400"
             Loaded="DynamicFormEditor_Loaded">
    <UserControl.Resources>
        <cvtrs:DynamicFormControlTypeEnumConverter x:Key="dynamicFormControlTypeEnumConverter" />
        <BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter" />
    </UserControl.Resources>

    <Border Margin="5"
            HorizontalAlignment="Stretch"
            BorderBrush="LightGray"
            BorderThickness="1"
            CornerRadius="5"
            Padding="5">
        <DockPanel Margin="3"
                   HorizontalAlignment="Stretch"
                   LastChildFill="True">
            <Grid DockPanel.Dock="Bottom" Visibility="{Binding Path=ShowFullDynamicFormContent, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Converter={StaticResource booleanToVisibilityConverter}}">
                <Grid x:Name="gridSilverlightDataFormFields"
                      Margin="0,5,0,5"
                      Visibility="Collapsed">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <DockPanel>
                        <TextBlock Margin="0,0,7,0"
                                   VerticalAlignment="Center"
                                   Text="Description" />
                        <TextBox Grid.Column="1" Text="{Binding Path=FieldDescription, Mode=TwoWay}" />
                    </DockPanel>
                    <DockPanel Grid.Row="1" Margin="0,5,0,0">
                        <TextBlock Margin="0,0,7,0"
                                   VerticalAlignment="Center"
                                   Text="Desc Viewer Position" />
                        <ComboBox Width="110"
                                  HorizontalAlignment="Left"
                                  FontSize="10"
                                  IsSynchronizedWithCurrentItem="True"
                                  Loaded="cboDescriptionViewerPosition_Loaded"
                                  SelectedValue="{Binding Path=DescriptionViewerPosition,
                                                          Mode=TwoWay}" />
                        <TextBlock Margin="7,0,7,0"
                                   VerticalAlignment="Center"
                                   Text="Label Position" />
                        <ComboBox Width="50"
                                  HorizontalAlignment="Left"
                                  FontSize="10"
                                  IsSynchronizedWithCurrentItem="True"
                                  Loaded="cboLabelPosition_Loaded"
                                  SelectedValue="{Binding Path=LabelPosition,
                                                          Mode=TwoWay}" />
                    </DockPanel>
                </Grid>
            </Grid>
            <Grid x:Name="gridDynamicFormControlEditor"
                  Margin="0,5,0,0"
                  DockPanel.Dock="Bottom"
                  Visibility="{Binding Path=ShowFullDynamicFormContent,
                                       RelativeSource={RelativeSource FindAncestor,
                                                                      AncestorType={x:Type Window}},
                                       Converter={StaticResource booleanToVisibilityConverter}}" />
            <Grid DockPanel.Dock="Bottom" Visibility="{Binding Path=ShowFullDynamicFormContent, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Converter={StaticResource booleanToVisibilityConverter}}">
                <CheckBox x:Name="chkRenderInDataColumnTemplate"
                          Margin="3"
                          VerticalAlignment="Center"
                          Content="Render In DataColumnTemplate"
                          IsChecked="{Binding Path=RenderAsGridTemplateColumn,
                                              Mode=Twoway}" />
            </Grid>
            <ComboBox Width="70"
                      HorizontalAlignment="Right"
                      DockPanel.Dock="Right"
                      Focusable="False"
                      FontSize="10"
                      IsSynchronizedWithCurrentItem="True"
                      Loaded="cboControlType_Loaded"
                      SelectedValue="{Binding Path=ControlType,
                                              Mode=TwoWay,
                                              Converter={StaticResource dynamicFormControlTypeEnumConverter}}"
                      SelectionChanged="cboControlType_SelectionChanged" />
            <TextBlock Margin="10,0,10,0"
                       HorizontalAlignment="Right"
                       DockPanel.Dock="Right"
                       Text="Control" />
            <TextBlock Width="40" Text="Path" />
            <TextBlock MaxWidth="150"
                       Margin="0,0,10,0"
                       FontWeight="Bold"
                       Text="{Binding Path=NameAndWriteable}"
                       TextTrimming="CharacterEllipsis">
                <TextBlock.ToolTip>
                    <ToolTip Content="{Binding Path=NameSpaceTypeName}" />
                </TextBlock.ToolTip>
            </TextBlock>
            <TextBlock Text="{Binding Path=DataType}" TextTrimming="CharacterEllipsis">
                <TextBlock.ToolTip>
                    <ToolTip Content="{Binding Path=NameSpaceTypeName}" />
                </TextBlock.ToolTip>
            </TextBlock>
        </DockPanel>
    </Border>

</UserControl>
